dgb: M3 §7b Scrypt-only multi-algo version classifier - #152
Merged
Conversation
DigiByte encodes the mining algo in 4 bits of the block nVersion field. The Scrypt-only V36 validation path needs a consensus-exact decode to route each incoming parent header: Scrypt -> PoW-validate, known non-Scrypt -> accept-by-continuity (work-neutral), unknown algo bits -> reject. Add coin/dgb_block_algo.hpp: a header-only SSOT (DgbAlgo, is_scrypt_header, dgb_header_disposition) pinning the BLOCK_VERSION_* / ALGO_* enums verbatim from DigiByte Core src/primitives/block.h + GetAlgo(). CRITICAL invariant: Scrypt == (0 << 8) -- the masked algo bits are ZERO -- so the gate is (nVersion & 0x0F00) == 0, not a nonzero check. Also pins the upstream quirk ALGO_ODO == 7 (not a dense 5) and rejects reserved codepoints (10/12 << 8). Add standalone guard test/algo_select_test.cpp (6 tests, GTest-only, no OBJECT lib) and register it in BOTH the ctest foreach allowlist and the two build.yml --target lists, per the #143 NOT_BUILT lesson. No header_chain or transport wiring touched; foundational primitive for the deferred validate()/DigiShield-window port.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
First slice of M3 §7b (SCRYPT-ONLY VALIDATION). Adds the consensus-exact DGB multi-algo block-version classifier that the deferred
coin/header_chain.hppvalidate()+ DigiShield Scrypt-only window walk both depend on.coin/dgb_block_algo.hpp(header-only SSOT):DgbAlgo,dgb_block_algo(),is_scrypt_header(),dgb_header_disposition()(three-way: VALIDATE_SCRYPT / ACCEPT_BY_CONTINUITY / REJECT).src/primitives/block.h(BLOCK_VERSION_*,ALGO_*) +block.cpp::GetAlgo().test/algo_select_test.cpp: 6-test standalone guard (GTest-only, links no OBJECT lib), wired into BOTH the ctest foreach allowlist AND bothbuild.yml--target lists (per the ci: build test_dgb_subsidy in both Linux test jobs (fix master-red NOT_BUILT) #143 NOT_BUILT lesson).Consensus notes
(0 << 8)— masked algo bits are ZERO. Gate is(nVersion & 0x0F00) == 0, not a nonzero check. Test asserts this directly (a bare primary-version header is Scrypt).ALGO_ODO == 7(not a dense 5); reserved codepoints (10/12 << 8 = Equihash/Ethash) decode to UNKNOWN -> REJECT.Verify
build EXIT=0,
algo_select_test6/6 PASS locally. Noheader_chain.hpp/transport touched.HOLD merge — operator push-approval card as usual.